package com.project.config;

import com.project.interceptor.LoginInterceptor;
import com.project.interceptor.RoomInterceptor;
import com.project.interceptor.TeacherInterceptor;
import com.project.interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/jpg/**")
                .addResourceLocations("file:C:/Users/86181/Desktop/lovo/lessonNotes/ClassroomPractice/JAVA/javaWeb/dorm/jpg/");


    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/homehtml/**")
                .addPathPatterns("/userhtml/**")
                .addPathPatterns("/managementhtml/**")
                .addPathPatterns("/roomhtml/**").
                addPathPatterns("/studenthtml/**");

        registry.addInterceptor(new UserInterceptor())
                .addPathPatterns("/managementhtml/**");

        registry.addInterceptor(new TeacherInterceptor())
                .addPathPatterns("/studenthtml/**");
        registry.addInterceptor(new RoomInterceptor())
                .addPathPatterns("/roomhtml/**");

    }


}
